import cloud from '@lafjs/cloud';
let dbName = "invoicing"
const db = cloud.mongo.db

export default async function (ctx) {
  const docs = await db.collection(dbName).find({ isInvoicing: 1 }).toArray()
  if (docs && docs.length) {
    for (let index = 0; index < docs.length; index++) {
      const element = docs[index];
      //更改发票状态
      await cloud.invoke("uni/invoice/queryOrder_noauth", { ...ctx, body: { ddlsh: element.ddlsh } })
    }
  }
  //生成总报表
  //await cloud.invoke("admin/report/production_bill_noauth", { ...ctx })
  // 返回内容
  return cloud.utils.requestReturn({ data: "ok" })
}